using Microsoft.AspNetCore.Mvc;
using star_questionnair.Models;
using star_questionnair.Services;
using star_questionnair.Services.impl;

namespace star_questionnair.Controllers;
[Route("sortQuestionAnalysis")]
[ApiController]
public class SortQuestionAnalysisController : ControllerBase
{
    private readonly ISortQuestionAnalysisService _sortQuestionAnalysisService;

    public SortQuestionAnalysisController(ISortQuestionAnalysisService sortQuestionAnalysisService)
    {
        _sortQuestionAnalysisService = sortQuestionAnalysisService;
    }
    // 获取排序选项的分数
    [HttpGet("optionScore/{questionId}")]
    public async Task<ActionResult<Dictionary<string, double>>> GetSortOptionScore(int questionId)
    {
        var result = await _sortQuestionAnalysisService.GetSortOptionScoreAsync(questionId);
        if (result != null)
            return Ok(new{success=true,data=result});
        return Ok(new { message = "No words found." });
    }

    // 获取排序选项的排名比例
    [HttpGet("optionRankingProportions/{questionId}")]
    public async Task<ActionResult<Dictionary<string, List<double>>>> GetSortOptionRankingProportions(int questionId)
    {
        var result = await _sortQuestionAnalysisService.GetSortOptionRankingProportionsAsync(questionId);
        if (result != null)
            return Ok(new{success=true,data=result});
        return Ok(new { message = "No words found." });
    }
    
}